package simple.entity

class Invoker {
    Invoker() {
        action = new Action()
    }

    void handleAction() {
        //init borrowers data
        def choice = action.readMenuSelection()
        while (choice != '0') {
            if (choice == '1') {
                action.addBook()
            } else if (choice == '2') {
                action.displayStock()
            } else if (choice == '3') {
                action.displayBooksAvailableForLoan()
            } else if (choice == '4') {
                action.displayBooksOnLoan()
            } else if (choice == '5') {
                action.registerBorrower()
            } else if (choice == '6') {
                action.displayBorrowers()
            } else if (choice == '7') {
                action.lendBook()
            } else if (choice == '8') {
                action.returnBook()
            } else if (choice == '9') {
                action.removeBook()
            } else {
                println("Unkown selection.")
            }
            choice = action.readMenuSelection()
        }
    }

    //----------properties----------
    def action

}
